package com.example.educationalsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.educationalsystem.entity.Vo.VoteRecordVo;
import com.example.educationalsystem.entity.VoteRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zpc
 * @since 2022-12-26
 */

@Repository
public interface IVoteRecordMapper extends BaseMapper<VoteRecord> {
    @Select("<script>" +
            "select a.*,b.student_name,d.teacher_name \n" +
            "from vote_record a  \n" +
            "left join student b on a.student_id=b.student_id \n" +
            "left join teacher d on a.teacher_id=d.teacher_id \n"+
            "</script>")
    List<VoteRecordVo> getAllVoteRecord();
    @Select("<script>" +
            "select a.*,b.student_name,d.teacher_name \n" +
            "from vote_record a  \n" +
            "left join student b on a.student_id=b.student_id \n" +
            "left join teacher d on a.teacher_id=d.teacher_id \n"+
            "<if test='ew != null'>" +
            " AND ${ew.SqlSegment}" +
            "</if>"
            + "</script>")
    Page<VoteRecordVo> getVoteRecordPage(Page<VoteRecordVo> page, @Param("ew") Wrapper wrapper);
}
